package com.example.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.stereotype.Component;

@Component
public class SchedulingConfigurerTask implements SchedulingConfigurer {

    private static final Logger logger = LoggerFactory.getLogger(SchedulingConfigurerTask.class);

    private String cron = "0/5 * * * * ?";


    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.addCronTask(() -> logger.info("======SchedulingConfigurerTask 定时任务执行======"),cron);
    }

    public String getCron() {
        return cron;
    }

    public void setCron(String cron) {
        this.cron = cron;
    }
}
